<title>部门查看</title>
<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-card">
    <div class="layui-card-header">部门查看</div>
    <form class="layui-form" action="" lay-filter="component-form-group" >
    <div class="layui-card-body" style="padding: 15px;" template template lay-url="/system/tsDept/findTsDept.do.do?deptId={{ layui.router().search.deptId }}">
      <div class="layui-form-item">
        <div class="layui-inline">
          <label class="layui-form-label required">部门名称</label>
          <div class="layui-input-inline">
            <input type="hidden" name="deptId" value="{{d.data.deptId}}" id="deptId"/>
            <input type="text" name="deptName" lay-verify="required|deptName" autocomplete="off" placeholder="请输入部门名称" class="layui-input" value="{{d.data.deptName}}">
          </div>
        </div>
        <div class="layui-inline">
          <label class="layui-form-label required">部门编码</label>
          <div class="layui-input-inline">
            <input type="text" name="deptCode" lay-verify="required|deptCode" autocomplete="off" placeholder="请输入部门编码" class="layui-input" value="{{d.data.deptCode}}">
          </div>
        </div>
        <div class="layui-inline">
          <label class="layui-form-label">上级部门</label>
          <div class="layui-input-inline">
            <input type="hidden" id="parentId" name="parentId" value="{{d.data.parentId}}" lay-filter="parentId" />
            <input type="text" id="parentName" disabled="disabled" name="parentName"
                   value="{{d.data.parentName}}" lay-verify="required|loginName"
                   autocomplete="off" placeholder="请选择" class="layui-input"  lay-filter="parentName">
          </div>
        </div>
      </div>
      <div class="layui-form-item" style="text-align: right">
        <div class="layui-input-block">
          <a lay-href="/dept/list" class="layui-btn layui-btn-primary">
            <i class="layui-icon layui-icon-return"></i>返回
          </a>
        </div>
      </div>

    </div>
    </form>
  </div>
  </div>
</div>

<script>
layui.use(['admin', 'form', 'laydate'], function(){
  var $ = layui.$,admin = layui.admin,element = layui.element
  ,layer = layui.layer
  ,laydate = layui.laydate
  ,form = layui.form;
  form.render(null,'component-form-group');
  laydate.render({
    elem: '#LAY-component-form-group-date'
  });
  /* 自定义验证规则 */
  form.verify({
    loginName: function(value){
      if(value.length < 5){
        return '标题至少得5个字符啊';
      }
    },pass: [/(.+){6,12}$/, '密码必须6到12位']
    ,content: function(value){
      layedit.sync(editIndex);
    }
  });

  /* 监听提交 */
  form.on('submit(component-form-ts-user)', function(data){
    admin.req({
       url: 'system/tsUser/saveTsUser.do' //实际使用请改成服务端真实接口
      ,data: data.field
      ,type:'get'
      ,done: function(res){
           if(res.code == 0){
             layer.msg(res.msg, {
               offset: '15px'
               ,icon: 1
               ,time: 1000
             }, function(){
               location.hash = '/user/user/list';
             });
           }else {
             layer.msg(res.msg, {
               offset: '15px'
               , icon: 2
               , time: 1000
             }, function () {
             });
             return ;
           }
      },success:function (res) {
        console.log(res)
      },error:function (res) {
        console.log(res)
      }});
    return false;
  });
});
</script>